import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '作业类型',
    align: "center",
    dataIndex: 'type_dictText'
  },
  {
    title: '安全措施',
    align: "center",
    dataIndex: 'measure'
  },
  {
    title: '确认岗位',
    align: "center",
    dataIndex: 'confirmPostion_dictText'
  },
  {
    title: '是否必选',
    align: "center",
    dataIndex: 'isNot_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "作业类型",
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "jobType"
    },
    //colProps: {span: 6},
  },
  {
    label: "安全措施",
    field: 'measure',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "确认岗位",
    field: 'confirmPostion',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_position,name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "是否必选",
    field: 'isNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '作业类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "jobType"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入作业类型!'},
             ];
    },
  },
  {
    label: '安全措施',
    field: 'measure',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入安全措施!'},
             ];
    },
  },
  {
    label: '确认岗位',
    field: 'confirmPostion',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sys_position,name,id"
    },
  },
  {
    label: '是否必选',
    field: 'isNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否必选!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  type: {title: '作业类型',order: 0,view: 'list', type: 'string',dictCode: 'jobType',},
  measure: {title: '安全措施',order: 1,view: 'textarea', type: 'string',},
  confirmPostion: {title: '确认岗位',order: 2,view: 'list', type: 'string',dictTable: 'sys_position', dictCode: 'id', dictText: 'name',},
  isNot: {title: '是否必选',order: 3,view: 'radio', type: 'string',},
};
